vapp = new Vue(
		{
			el : '#app',
			data : {

				pageSizes : config.pageSizes,
				currentPageNbr : config.currentPageNbr,
				pageSize : config.defaultpageSize,
				totalRecords : 0,
				defaultProps : {},
				filterText : '',// 节点过滤
				curTreeId : '5',// 监控树的节点id
				curTreeLevel : '3',// 当前树的层级
				treeRootId : '0',// 树根节点
				privtablist : [],
				deptName : '',
				realName : '',
				groupOrder : '1',
				privlist : [],
				editable : [],// 编辑列数组
				rowDbFlag : true, // 行是否可以双击标识
				tmpEditableVal : '', // 临时存储数据
				selectabled : true,
				dialogFormVisible : false,
				form : {
					title : '权限信息-',
					privname:"",
					remarks:"",
					privgroup:"",
					privcode:"",
					grouporder:""
				},

			},
			created : function() {

				tools.loadDiv();

			},
			mounted : function() {
				var that = this;
//				user.getUserInfo(function(data) {

					//alert(JSON.stringify(data));
					//alert(data.userinfo.curDeptName);
//					that.deptName = data.userinfo.curDeptName;
					// alert(data.userinfo.privDeptId);
//					that.treeRootId = data.userinfo.privDeptId;
//					that.curTreeId = data.userinfo.privDeptId;
//					that.curTreeLevel = data.userinfo.privDeptLevel;

					that.getPrivtabList();
					that.getPrivList();
//				});

			},
			methods : {

				getPrivtabList : function() {
				    var reqData= {"jsondata": "{}"};
					data = tools.ajaxRequest(
							"../../pub/privilege/privilegeListMenu", reqData);
					console.log(data);
					if (data.respCode == "0"
							&& (data.privlist != undefined ? data.privlist.length
									: 0)) {
						this.privtablist = data.privlist;
					} else {
						this.privtablist = [];
					}

				},
				getPrivList : function() {
					var that = this;

					var postdata = {
						"groupOrder" : this.groupOrder

					};
					var reqData= {"jsondata": JSON.stringify(postdata)};
					// alert(JSON.stringify(postdata));
					tools
							.ajaxRequestAsync(
									"../../pub/privilege/privilegeListMain",
									reqData,
									function(v) {
										console.log(v);
										if (v.respCode == "0"
												&& (v.privlist != undefined ? v.privlist.length
														: 0)) {
											that.privlist = v.privlist;
										} else {
											that.privlist = [];
										}
									});
				},
				handleClick : function(tab, event) {
					console.log(tab, event);
					this.groupOrder = tab.name;
					this.getPrivList();
				},
				openDialogForm:function(){
					this.form.privname="";
				this.form.remarks="";
				this.form.privgroup="";
				this.form.privcode="";
				this.form.grouporder="";
				this.selectabled=false;
				this.dialogFormVisible=true;
				
				},
				selectGetLabel:function(vid){
				     console.log(vid);
				      let obj = {};
				      obj = this.privtablist.find((item)=>{
				          return item.grouporder === vid;
				      });
				      console.log(obj.privgroup);
				      this.form.privgroup=obj.privgroup;
				},
				savePriv:function(){
					console.log(this.form);
					var that = this;

					var postdata = {
							"privCode" : this.form.privcode,
							"privName" : this.form.privname,
							"remarks" : this.form.remarks,
							"groupOrder" : this.form.grouporder,
							"privGroup" : this.form.privgroup

					};
					var reqData= {"jsondata": JSON.stringify(postdata)};
					// alert(JSON.stringify(postdata));
					tools
							.ajaxRequestAsync(
									"../../pub/privilege/privilegeSave",
									reqData,
									function(v) {
										console.log(v);
										if (v.respCode == "0") {
											that.dialogFormVisible=false;
											that.groupOrder=that.form.grouporder;
											that.getPrivList();
											 that.$message({
										        	showClose: true,
										            type: 'success',
										            message: '保存成功!'
										          });
										} else {
											that.$message({
									        	showClose: true,
									        	 type: 'info',
									            message: '保存失败!'
									          });
										}
									});
				},
				edit : function(index, row) {
					console.log(index, row);
					this.form.privname=row.privname;
					this.form.remarks=row.remarks;
					this.form.privgroup=row.privgroup;
					this.form.privcode=row.privcode;
					this.form.grouporder=row.grouporder;
					this.selectabled=true;
					this.dialogFormVisible=true;
					
				},
				del : function(index, row) {
					console.log(index, row);
					var that=this;
					// alert(JSON.stringify(row));
					
					this.$confirm('此操作将永久删除 "'+row.remarks+'", 是否继续?', '提示', {
				          confirmButtonText: '确定',
				          cancelButtonText: '取消',
				          type: 'warning'
				        }).then(() => {
				        	
				      
				        	var postdata = {
									"privCode" : row.privcode,				

								};
				        	var reqData= {"jsondata": JSON.stringify(postdata)};
				    		tools
							.ajaxRequestAsync(
									"../../pub/privilege/privilegeDel",
									reqData,
									function(v) {

										if (v.respCode == "0") {
											that.getPrivList();
											 that.$message({
										        	showClose: true,
										            type: 'success',
										            message: '删除成功!'
										          });								
										} else {
											 that.$message({
										        	showClose: true,
										        	 type: 'info',
										            message: '删除失败!'
										          });						
										}
									});
				          
				        }).catch(() => {
				          this.$message({
				        	showClose: true,
				            type: 'info',
				            message: '已取消删除',
				          });          
				    });
				}
			}

		});
